<template>
	<view class="main">
		<view class="pdf" style="height: 92vh;overflow: auto;">
			<pdf v-for="i in num" :key="i" :src="addr" :page="i"></pdf>
		</view>
		<view class="title" style="display: flex;justify-content: flex-end;margin: 10px 16px 0px 0px;">
			<view class="text" @click="jump" style="color: #3c9cff;border-bottom: #3c9cff 1.2px solid;">
				跳 转 到 浏 览 器 下 载
			</view>
		</view>
	</view>
</template>

<script>
	import croods from '@/common/croods-1.3.3.js';
	window.croods = croods;
	window.hydra = require('../../../../common/wst_hydra-1.0.0.js');


	import pdf from 'vue-pdf'
	export default {
		components: {
			pdf
		},
		onLoad: function(option) {
			this.addr = option.addr
		},
		data() {
			return {
				addr: '',
				num: 1
			}
		},
		methods: {
			getNum() {
				let loadingTask = pdf.createLoadingTask(this.addr)
				loadingTask.promise.then(pdf => {
					this.num = pdf.numPages
				}).catch((err) => {
					console.log(err)
				})
			},
			jump() {
				window.croods.customPlugin({
					action: 'UtilPlugin.openURLScheme',
					params: {
						urlScheme: this.addr
					},
					success: function(res) {

					},
					fail: function(msg) {

					}
				})
			}
		},
		onShow() {
			document.body.style.overflow = 'auto';
		},
		mounted() {
			this.getNum()
		}
	}
</script>

<style scoped>

</style>